package com.puzzlebazar.client.puzzle.model;

/**
 * A move that modifies the history, like undo or redo
 * 
 * @author beaudoin
 *
 */
public abstract class HistoryMove extends MoveImpl {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3092722294398265748L;
	
	/**
	 * The puzzle move associated with this history move
	 */
	protected Move puzzleMove;
	
	/**
	 * Only for serialization
	 */
	protected HistoryMove() {
		super();
	}
	
	public HistoryMove( Move puzzleMove ) {
		super( puzzleMove.getTime() );
		this.puzzleMove = puzzleMove;
	}
	
	/**
	 * @return The puzzle move corresponding to this history move
	 */
	public Move getPuzzleMove() {
		return puzzleMove;
	}

	@Override
	public Move apply(PuzzleModel model) throws Exception {
		return puzzleMove.apply(model);
	}

	@Override
	public Move unapply(PuzzleModel model) throws Exception {
		return puzzleMove.unapply(model);
	}

}
